package com.frank.minio.upload.configuration;


import com.frank.minio.upload.model.CustomMinioClient;
import com.frank.minio.upload.properties.MinioProperties;
import com.frank.minio.upload.service.MinioUtils;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Minio 配置信息
 *
 * @author frank
 */
@Configuration
public class MinioConfig {
    @Autowired
    private MinioProperties minioProperties;

    /**
     * 供Utils类使用
     */
    @Bean("minioUtils")
    public MinioUtils minioUtils() {
        MinioClient build = MinioClient.builder().endpoint(minioProperties.getEndpoint()).credentials(minioProperties.getAccessKey(), minioProperties.getAccessSecret()).build();
        CustomMinioClient client = new CustomMinioClient(build);
        return new MinioUtils(client);
    }
}
